<?
    require_once("mvc/action/ActionForm.php");
    require_once("mvc/action/ActionMessage.php");
    require_once("mvc/action/ActionMessages.php");

    require_once("cms/guide/om/GuideI18n.php");


    class BaseGuideForm extends ActionForm {

        protected $guideI18n;
        protected $formImage;
        protected $deleteImage;

        public function __construct() {
            $this->guideI18n = new GuideI18n();
            $this->formImage = null;
            $this->deleteImage = false;
        }

        public function getGuideI18n() {
            return $this->guideI18n;
        }

        public function setGuideI18n(GuideI18n $guideI18n) {
            $this->guideI18n = $guideI18n;
        }

        public function getFormImage() {
            return $this->formImage;
        }

        public function setFormImage($formImage) {
            $this->formImage = $formImage;
        }

        public function getDeleteImage() {
            return $this->deleteImage;
        }

        public function setDeleteImage($deleteImage) {
            $this->deleteImage = $deleteImage;
        }

        public function validate() {

            $errors = new ActionMessages();

            if(is_null($this->getGuideI18n()->getDescription1()) || strlen($this->getGuideI18n()->getDescription1()) == 0)
                $errors->add("guideI18n->description1",
                    new ActionMessage("errors.required", true, new ActionMessage("prompt.info", true)));


            if(is_null($this->getGuideI18n()->getDescription2()) || strlen($this->getGuideI18n()->getDescription2()) == 0)
                $errors->add("guideI18n->description2",
                    new ActionMessage("errors.required", true, new ActionMessage("prompt.un", true)));


            global $ALLOWABLE_IMAGES;
            if(!is_null($this->getFormImage()) && isset($this->formImage["size"]) && $this->formImage["size"] > 0 && !array_key_exists($this->formImage["type"], $ALLOWABLE_IMAGES))
                $errors->add("formImage",
                    new ActionMessage("errors.image", true, new ActionMessage("prompt.image", true)));

            return $errors;
        }

    }
?>